<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<link rel="stylesheet" media="screen" href="css/docs.css"/>
<link rel="stylesheet" media="screen" href="lib/jqplot/jquery.jqplot.min.css"/>
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>

<script type="text/javascript" src="${ctx}/js/global_util.js"></script>

<h1 class="page-title">员工离职申请 - 申请</h1>

<div class="container_12 clearfix leading">
    <div class="side grid_12 leading">
        <form class="form has-validation" id="post_form" name="post_form">
            <div class="clear"></div>
            <div class="clearfix">
                <label for="a_leaveDate" class="form-label">离职时间 <em>*</em></label>
                <div class="form-input">
                    <input type="text" id="a_leaveDate" name="apply_leaveDate" required="required" placeholder="请输入离职日期" onfocus="WdatePicker({minDate:'%y-%M-%d'})" readonly="readonly" value='<s:date name="#request.apply.leaveDate" format="yyyy-MM-dd" />'/>
                </div>
            </div>

            <div class="clear"></div>
            <div class="clearfix">
                <label for="a_leaveReason" class="form-label">离职理由 <em>*</em></label>
                <div class="form-input">
                    <textarea name="apply.leaveReason" rows="5" required="required" id="a_leaveReason" placeholder="请输入离职理由">${apply.leaveReason}</textarea>
                </div>
            </div>

            <input type="hidden" name="apply.id" value="${apply.id}">
            <div class="form-action clearfix">
                <button class="button" type="button" onclick="checkForm()">${apply == null ? "申请" : "修改"}</button>
                <button class="button" type="reset">重置</button>
                <a class="button" href="#public/leave-office-apply-list.xhtml"><span style="background:url(${ctx}/images/img/arrow_undo.png)" class="icon">&nbsp;</span>返回</a>
            </div>
        </form>
    </div>
</div>

<div class="clear"></div>

<script type="text/javascript" src="js/Tree.js"></script>
<script type="text/javascript">
    function checkForm() {
        var a_leaveDate = $("#a_leaveDate").val();
        if (checkNull(a_leaveDate)) {
            alert("请输入离职日期");
            return;
        }
        var a_leaveReason = $("#a_leaveReason").val();
        if (checkNull(a_leaveReason)) {
            alert("请输入离职理由");
            return;
        }

        var data = $("#post_form").serialize();
        var url = "${ctx}/public/leave-office-apply-save.xhtml";
        $.ajax(url, {
            type:"POST",
            data:data,
            dataType:"html",
            cache:false,
            success:function (a) {
                return pageDownloaded(a, url)
            },
            complete:function () {
            }
        });
    }
</script>